<?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	  xmlns:composite="http://java.sun.com/jsf/composite"
	  xmlns:c="http://java.sun.com/jsp/jstl/core"
	  xmlns:f="http://java.sun.com/jsf/core"
	  xmlns:h="http://java.sun.com/jsf/html"
	  xmlns:ui="http://java.sun.com/jsf/facelets"
	  xmlns:framework="http://java.sun.com/jsf/composite/framework">
	  
	 <composite:interface>
		<composite:attribute name="searchEntity"/>
		<composite:attribute name="options"/>
	</composite:interface>
	
	<composite:implementation>
		
		<h:form>
				<table>
					<caption>Options</caption>	
					<composite:renderFacet name="options"></composite:renderFacet>													
					<tr>
						<th></th>
						<td>
							<h:commandButton action="#{cc.attrs.searchEntity.searchEntity}"
											 value="Search"/>
						</td>
					</tr>	
															
				</table>
				<h:messages/>
			</h:form>		
			
			<c:if test="#{cc.attrs.searchEntity.pages != null and cc.attrs.searchEntity.pages.size() > 0}">
				<h:form>
					<h:dataTable value="#{cc.attrs.searchEntity.result}"
								 var="entity">
						<f:facet name="caption">Result</f:facet>	
										
						<composite:insertChildren />	
															
					</h:dataTable>
		
					<div class="pagination">
						<h:commandButton action="#{cc.attrs.searchEntity.goToFirst()}"
										 disabled="#{cc.attrs.searchEntity.page == 1}"
						   			     value="First">
							<f:ajax render="@form"/>
						</h:commandButton>
						<h:commandButton action="#{cc.attrs.searchEntity.goToPrevious()}"
										 disabled="#{cc.attrs.searchEntity.page == 1}"
						   			     value="Previous">	
							<f:ajax render="@form"/>
						</h:commandButton>   			     
						<ui:repeat value="#{cc.attrs.searchEntity.pages}"
								   var="page">
							<h:commandLink action="#{cc.attrs.searchEntity.goTo(page)}"
										   disabled="#{page == cc.attrs.searchEntity.page}"
										   value="#{page}">
								<f:ajax render="@form"/>
							</h:commandLink>
						</ui:repeat>			
						<h:commandButton action="#{cc.attrs.searchEntity.goToNext()}"
										 disabled="#{cc.attrs.searchEntity.page == cc.attrs.searchEntity.pages.size()}"
						   			     value="Next"/>					   	
						<h:commandButton action="#{cc.attrs.searchEntity.goToLast()}"
										 disabled="#{cc.attrs.searchEntity.page == cc.attrs.searchEntity.pages.size()}"
						   			     value="Last"/>			   			   										
					</div>
				</h:form>
			</c:if>	
	
	</composite:implementation>
	
	
</html>
